﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace BAL
{
    public class UploadUtils
    {
        public const long AvatarUploadMaxSize = 2097152;
        public const int AvatarMaxWidth = 4800;
        public const int AvatarMaxHeight = 3600;
        public const int AvatarMinWidth = 220;
        public const int AvatarMinHeight = 330;
        public const int AvatarThumbWith = 600;
        public const int ImageMinWidth = 600;
        //public const long ImagesUploadMaxSize = 2097152;
        public const long ImagesUploadMaxSize = 5097152;
        public const int TimeExpire = 60;
        //public const int ImagesUploadMaxItems = 31;
        public const int ImagesUploadMaxItems = 4;

        public static string GenerateUserImagesFileName(string extention)
        {
            string format = "yyyyMMddHHmmssFFFF";
            return ConfigurationManager.AppSettings["FormatNameFile"].ToString() + DateTime.Now.ToString(format) + extention;
        }

        public static string GenerateUserImagesFolder()
        {
            return "/upload/web/userimages/" + DateTime.Now.ToString("yyyyMMdd") + "/";
        }

        public static string GenerateCropUserImagesFolder()
        {
            return "upload\\web\\userimages\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
        }

        public static string GenerateUserThumbImagesFolder()
        {
            return "/upload/web/thumbimages/" + DateTime.Now.ToString("yyyyMMdd") + "/";
        }

        public static string CutImageName(string path)
        {
            return path.Substring(path.LastIndexOf("/") + 1, path.Length - path.LastIndexOf("/") - 1);
        }
    }
}
